import { createSlice } from "@reduxjs/toolkit";

interface CategoryType {
  id: number;
  categoryName: string;
}

const initialState: {
  categoryList: CategoryType[];
  active: number;
  businessCategoryList: CategoryType[];
} = {
  categoryList: [],
  businessCategoryList: [],
  active: 0,
};

const categorySlice = createSlice({
  name: "category",
  initialState,
  reducers: {
    setCategory(state, action) {
      state.categoryList = action.payload;
    },
    setBusinessCategory(state, action) {
      state.businessCategoryList = action.payload;
    },
    setActive(state, action) {
      state.active = action.payload;
    },
  },
});

export default categorySlice.reducer;
export const { setCategory, setActive, setBusinessCategory } =
  categorySlice.actions;
